package oop.ex1.filters;
//*********
//IMPORTS
//*********
import java.util.regex.Pattern;

//###############
//FILE : TextFilter.java
//WRITER : Amir Wilf, wilfoa, 300007085
//WRITER : Daniel Acherkan, danithelion, 310116348
//EXERCISE : oop ex1 2011
//DESCRIPTION:
//An abstract class for filtering files according to a text pattern
//###############

public abstract class TextFilter extends Filter {
	
	//*********
    //CONSTANTS
    //*********
	/**
	 * the operating system file separator sign
	 */
	final protected String SLASH = System.getProperty("file.separator");
	/**
	 * the REGEX substitute sign
	 */
	final protected String SUBSTITUTE = "\\";
	/**
	 * symbolizes the user's symbol for 'every letter or character'
	 */
	final protected String STAR = "*";
	/**
	 * symbolizes the REGEX for zero or more of any character
	 */
	final protected String DOT = ".";
	/**
	 * the REGEX form of 'every letter or character'
	 */
	final protected String FIND_ALL = ".*";
	
	//************
    //DATA MEMBERS
    //************
	
	//the String which holds the filter 
	protected String _textpatt;
	//processes pattern to match on text
	protected Pattern _pattern;
	protected boolean _exclude;
	
	//************
	//METHODS
	//************
	/**
	 * Constructor for the abstract class
	 * @param text the text pattern to match
	 */
	public TextFilter(String text,boolean exclude){
		super(false);
		_exclude = exclude;
		_textpatt = text;
		parsePattern(this._textpatt);
	}
	
	/**
	 * The method which parses the pattern to a java Pattern class
	 * @param text - the text to process into a Pattern
	 */
	protected abstract void parsePattern(String text);

}

